var userId="";

var myChart = echarts.init(document.getElementById('pieEchart'),'macarons');



option = {
	    title : {
	        text: '某站点用户访问来源',
	        subtext: '纯属虚构',
	        x:'center'
	    },
	    tooltip : {
	        trigger: 'item',
	        formatter: "{a} <br/>{b} : {c} ({d}%)"
	    },
	    legend: {
	        orient: 'vertical',
	        left: 'left',
	        data: ['直接访问','邮件营销','联盟广告','视频广告','搜索引擎']
	    },
	    series : [
	        {
	            name: '访问来源',
	            type: 'pie',
	            radius : '55%',
	            center: ['50%', '60%'],
	            data:[
	                {value:335, name:'直接访问'},
	                {value:310, name:'邮件营销'},
	                {value:234, name:'联盟广告'},
	                {value:135, name:'视频广告'},
	                {value:1548, name:'搜索引擎'}
	            ],
	            itemStyle: {
	                emphasis: {
	                    shadowBlur: 10,
	                    shadowOffsetX: 0,
	                    shadowColor: 'rgba(0, 0, 0, 0.5)'
	                }
	            }
	        }
	    ]
	};


$(function(){
	getCharts();
});
function getScore(x){
    var f = parseFloat(x);   
    if (isNaN(f)) {   
      return false;   
    }   
    var f = Math.round(x*100)/100;   
    var s = f.toString();   
    var rs = s.indexOf('.');   
    if (rs < 0) {   
      rs = s.length;   
      s += '.';   
    }   
    while (s.length <= rs + 2) {   
      s += '0';   
    }   
    return s;   
  }  
function getCharts(){
	var thisURL = document.URL;  
	var  getval =thisURL.split('?')[1];
	reportId= getval.split("=")[1];

	$.ajax({
		url : "../UserPaperController/findBygroup.action",
		dataType : 'json',  
		async : false,  
		data:{"reportId":reportId,
               
		}, 
		success : function(data) {
			$.each(data, function(i, n) {	
				$("#paperName").html(n.paperName);
			});
			option.xAxis[0].data = [];
			option.series[0].data = [];
			option.series[1].data = [];
			option1.xAxis[0].data = [];
			option1.series[0].data = [];
			var titleScoreString=data.avgScore;
			var titleTypeListAll=data.titleTypeListAll;
			var agvall=data.avgListAll;
			var sumRight=data.SumList;
			var sumString=data.sumScore;
			var listExtend=data.listExtend;
			var str="";
			var userInfo=data.user;
			var userInformation="";
			userInformation='<table width="90%" border="0" align="center" cellpadding="0"cellspacing="0">'+
			'<tr>'+
			'<td align="center" style="padding-top: 15px;">'+
			'<table width="100%" border="0" cellspacing="0" cellpadding="0" style="border: 1px solid #CCCCCC;">'+
			'<tr>'+
			'<td width="30%" align="center" style="border-right: 1px solid #CCCCCC;">'+
			'<table width="100%" border="0" cellspacing="0" cellpadding="0">'+
			'<tr>'+
			'<td align="center" style="font-family:"黑体"; font-size: 18px; font-weight: bold;">'+
			userInfo.userName+' </td>'+
			'</tr>'+
			'</table>'+
			'</td>'+
			'<td align="center">'+
			'<table width="98%" border="0" cellspacing="0" cellpadding="0"	style="font-size: 10px">'+
			'<tr>'+
			'<td width="20%" align="right" style="padding-right: 10px">'+
			"性&nbsp;&nbsp;&nbsp;&nbsp;别："+'</td>'+
			'<td width="30%" align="left">'+userInfo.userSex+'</td>'+
			'<td width="20%" align="right" style="padding-right: 10px">'+
			"专&nbsp;&nbsp;业："+'</td>'+
			'<td width="30%" align="left">'+userInfo.userMajor+'</td>'+
			'</tr>'+
			'<tr>'+
			'<td align="right" style="padding-right: 10px">'+
			"学&nbsp;&nbsp;&nbsp;&nbsp;历："+'</td>'+
			'<td align="left">'+userInfo.userEducation+'</td>'+
			'<td align="right" style="padding-right: 10px">'+"应聘职位："+'</td>'+
			'<td align="left">'+userInfo.userPosition+'</td>'+
			'</tr>'+
			'<tr>'+
			'<td align="right" style="padding-right: 10px">'+
			"住&nbsp;&nbsp;&nbsp;&nbsp;址："+'</td>'+
			'<td align="left">'+userInfo.userAddress+'</td>'+
			'<td align="right" style="padding-right: 10px">'+"测评日期："+'</td>'+
			'<td align="left">'+userInfo.create_time+'</td>'+
			'</tr>'+
			'</table>'+
			'</td>'+
			'</tr>'+
			'</table>'+
			'</td>'+
			'</tr>'+
			'</table>';
			$("#userInformation").html(userInformation);
			var paper=data.paper;
			var str1="";
			str1="<span>"+"本测试共"+paper.number+"题，规定时间"+paper.time+"分钟，该同学得分"+data.userPaperList[0].sumScore+"分"+"</span>";
			$("#userContent").html(str1);
			
			for(var i=0;i<titleScoreString.length;i++){
				
				if(titleScoreString[i]>agvall[i]){
					if(sumString[i]>(sumRight[i]*0.8)){			
						str='<span>'+userInfo.userName+"的"+titleTypeListAll[i].titleTypename+"较为优秀,"+titleTypeListAll[i].levelA+'</span>';//,能够熟练的学习和掌握与数学有关的知识，并很好的利用数学技能解决工作当中的实际问题。拥有优秀的图形认知和推理能力，能够很好的加工空间和平面几何体的相关信息，并发现其中的逻辑关系。能够清楚的表达自己的情感和思想，很好的理解和支持别人，不论同事还是朋友，上级还是下级，都能和他们保持良好的言谈关系。"+'</span>';				
					}
					else if(sumString[i]>(sumRight[i]*0.6)){
						str='<span>'+userInfo.userName+"的"+titleTypeListAll[i].titleTypename+"较为良好,"+titleTypeListAll[i].levelB+'</span>';

					}
					else{
						str='<span>'+userInfo.userName+"的"+titleTypeListAll[i].titleTypename+"还需要进一步加强,"+titleTypeListAll[i].levelC+'</span>';
					}

				}
				else{
					str='<span>'+userInfo.userName+"的"+titleTypeListAll[i].titleTypename+"还需要进一步的提升,"+titleTypeListAll[i].levelD+'</span>';
				}
				
					str+='<br>'


				option.series[0].data.push(getScore(agvall[i]));
				option.series[1].data.push(titleScoreString[i]);
				option.xAxis[0].data.push(titleTypeListAll[i].titleTypename);
				option1.xAxis[0].data.push(titleTypeListAll[i].titleTypename);
				option1.series[0].data.push(sumString[i]);
			
				$('#content').append(str);
			}

			var newstr="";
			var theaveragpoint=0;
			for(var i=0;i<sumString.length;i++)
			{
				theaveragpoint+=sumString[i];
			}
			  theaveragpoint/=sumString.length;
			for(var i=0;i<sumString.length;i++)
			{
				if(sumString[i]>theaveragpoint)
				{
					newstr+="<span>适合从事:"+titleTypeListAll[i].extend2+"等工作"+"</span>";
				}
			}

			$('#content').append(newstr);

			myChart.setOption(option,true);
			myChart.resize();
			myChart2.setOption(option1,true);
			myChart2.resize();
		}
	});

}